<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/WEB-INF/templates/basic_template.xhtml">

	<ui:define name="content">
		<h:form>
		<h:inputHidden value="#{experimentMBean.experiment.id}" />
		<br />
			<p:fieldset legend="Parâmetros do controlador" ajax="false">
				<!-- MALHA ABERTA -->
				<h:panelGroup id="loadOpenLoop"
					rendered="#{experimentMBean.isInstanceOfManualController()}">
					<ui:include src="loadOpenLoop.xhtml" />
				</h:panelGroup>

				<!-- CONTROLADOR PID -->
				<h:panelGroup id="loadPID"
					rendered="#{experimentMBean.isInstanceOfPidController()}">
					<ui:include src="loadPID.xhtml" />
				</h:panelGroup>
				
				<hr />

				<h:panelGrid columns="3" style="margin-bottom:7px" cellpadding="3" >
					<h:outputText value="Conexão: " />
					<p:selectOneRadio value="#{experimentMBean.local}" >
						<f:selectItem itemLabel="Simulador" itemValue="0" />
						<f:selectItem itemLabel="Planta real" itemValue="1" />
					</p:selectOneRadio>
				</h:panelGrid>
				
				<!-- LIGAR / DESLIGAR -->
				<h:panelGrid id="grid2" columns="3" style="margin-bottom:10px">
					<p:commandButton actionListener="#{experimentMBean.desligar}"
						value="Desligar" id="desligar"
						disabled="#{not experimentMBean.threadControle.ativa}"
						update="desligar" />
					<p:commandButton actionListener="#{experimentMBean.execute}"
						value="Enviar" id="ligar" update="desligar" />
					<p:commandButton actionListener="#{experimentMBean.save}"
						value="Salvar" id="salvar"  />
				</h:panelGrid>

			</p:fieldset>

			<br />
			

		</h:form>
		<h:form>
			<!-- GRÁFICO -->
			<p:poll id="poll" interval="1" update="chart" ajax="true" />
			<p:lineChart id="chart" value="#{experimentMBean.linearModel}" ajax="true" 
				legendPosition="sw" title="RESPOSTA DO SISTEMA" style="height:350px"
				showMarkers="false" />
		</h:form>

	</ui:define>
</ui:composition>
</html>